package com.cnzz.site1255174697.holder;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.cnzz.site1255174697.R;
import com.cnzz.site1255174697.model.MallObjectEntity;
import com.cnzz.site1255174697.model.MallTuiEntity;
import com.cnzz.site1255174697.utils.AlibcTradeUtils;
import com.cqyanyu.yanyu.view.recyclerView.YViewHolder;
import com.facebook.drawee.view.SimpleDraweeView;

/**
 * Created by yykj on 2016/11/5.
 */
public class GoodsObjectHolder extends YViewHolder<MallObjectEntity> {

    protected SimpleDraweeView imageGoods;
    protected TextView tvGoodsName;
    protected TextView tvPrice;
    protected TextView tvCostPrice;
    protected TextView tvPayNum;
    private MallObjectEntity mallObjectEntity;

    public GoodsObjectHolder(View parent) {
        super(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_mall_list, null));
        imageGoods = (SimpleDraweeView) itemView.findViewById(R.id.image_goods);
        tvGoodsName = (TextView) itemView.findViewById(R.id.tv_goodsName);
        tvPrice = (TextView) itemView.findViewById(R.id.tv_price);
        tvCostPrice = (TextView) itemView.findViewById(R.id.tv_cost_price);
        tvPayNum = (TextView) itemView.findViewById(R.id.tv_pay_num);
    }

    @Override
    public void onBindViewHolder(MallObjectEntity itemData) {
        super.onBindViewHolder(itemData);
        mallObjectEntity = itemData;
        imageGoods.setImageURI(itemData.getData().getItems().getX_item().getPic_url());
        tvGoodsName.setText(itemData.getData().getItems().getX_item().getTitle());
        tvPrice.setText(itemData.getData().getItems().getX_item().getPrice());
    }
    @Override
    public void onClick(View v) {
        super.onClick(v);
        AlibcTradeUtils.showUrl((Activity) mContext, mallObjectEntity.getData().getItems().getX_item().getAction_url());
    }

}
